//
//  CameraManagerConst.h
//  YPC-Time-siso
//
//  Created by dsw on 2019/8/29.
//  Copyright © 2019 i4season. All rights reserved.
//

#import <Foundation/Foundation.h>

/// 连接状态
typedef NS_ENUM(NSInteger, CMConnectStatus) {
    /** 连接失败 */
    CMConnectError = -1,
    /** 连接断开 */
    CMConnectDisconnected = 0,
    /** 正在连接 */
    CMConnectConnecting = 1,
    /// 连接成功 正在检查License
    CMConnectConnectedAndCheckingLicence = 2,
    /** 连接成功 License校验失败 继续执行 （漏烧）*/
    CMConnectErrorButContinue = 3,
    /** 连接完成 */
    CMConnectConnected = 4,
};

/** 连接状态 */
typedef NS_ENUM(NSInteger, CameraConnectStatus)
{
    /** 连接失败 */
    CameraConnectDeviceError = CMConnectError,
    /** 连接断开 */
    CameraConnectDeviceDisconnected = CMConnectDisconnected,
    /** 正在连接 */
    CameraConnectDeviceConnecting = CMConnectConnecting,
    /// 连接成功 正在检查License
    CameraConnectDeviceConnectedAndCheckingLicence = CMConnectConnectedAndCheckingLicence,
    /** 连接成功 License校验失败 继续执行 （漏烧）*/
    CameraConnectDeviceConnectedAndNoLicenceButContinue = CMConnectErrorButContinue,
    CameraConnectDeviceErrorButContinue = CMConnectErrorButContinue,
    /** 连接完成 */
    CameraConnectDeviceConnected = CMConnectConnected,
} DEPRECATED_MSG_ATTRIBUTE("use CMConnectStatus");

/// 状态是否为已连接, 包括 License错误但继续的状态
static inline BOOL CameraConnectStatusIsConnected(CameraConnectStatus status) {
    return ((status) == CameraConnectDeviceConnected || (status) == CameraConnectDeviceErrorButContinue);
}

//typedef NS_ENUM(NSInteger, CMRecordStatus)
//{
//    CMRecordNone,
//    CMRecordTakingPhoto,//拍照中
//    CMRecordTakePhotoEnd,//拍照完成
//    CMRecordTakePhotoError,//拍照错误
//    CMRecordWillRecord,//准备录制
//    CMRecordRecording,//录制中
//    CMRecordRecordEnd,//录制完成
//    CMRecordRecordError,//录制失败
//};

//typedef NS_ENUM(NSInteger, CameraProgramRecordStatus)
//{
//    CameraProgramRecordNone = CMRecordNone,
//    CameraProgramRecordTakePhoto = CMRecordTakingPhoto,//拍照中
//    CameraProgramRecordTakingPhoto = CMRecordTakingPhoto,//拍照中
//    CameraProgramRecordTakePhotoEnd = CMRecordTakePhotoEnd,//拍照完成
//    CameraProgramRecordTakePhotoError = CMRecordTakePhotoError,//拍照错误
//    CameraProgramRecordWillRecord = CMRecordWillRecord,//准备录制
//    CameraProgramRecordRecording = CMRecordRecording,//录制中
//    CameraProgramRecordRecordEnd = CMRecordRecordEnd,//录制完成
//    CameraProgramRecordRecordError = CMRecordRecordError,//录制失败
//} DEPRECATED_MSG_ATTRIBUTE("use CMRecordStatus");

/// 设备连接方式
typedef NS_ENUM(NSInteger, CMConnectType)
{
    CMConnectUnknow,
    CMConnectI4WiFi,
    CMConnectI4USB,
    CMConnectI4MFI,
    /// BK WIFi新方案
    CMConnectBKWiFi,
    /// BK WIFi 衍生的方案 铁牛
    CMConnectTNWiFi,
    /// 乐信设备
    CMConnectLX,
    /// 新廉价方案
    CMConnectSoSo,
    /// 新MFI方案
    CMConnectZMFI,
    /// MTP 方案
    CMConnectMTP,
    CMConnectUVC,
};

/// 设备连接方式
//typedef NS_ENUM(NSInteger, CameraConnectType)
//{
//    CameraConnectTypeUnknow = CMConnectUnknow,
//    CameraConnectTypeI4WiFi = CMConnectI4WiFi,
//    CameraConnectTypeI4USB = CMConnectI4USB,
//    CameraConnectTypeI4MFI = CMConnectI4MFI,
//    /// BK WIFi新方案
//    CameraConnectTypeBKWiFi = CMConnectBKWiFi,
//    /// 乐信设备
//    CameraConnectTypeLX = CMConnectLX,
//    /// 新廉价方案
//    CameraConnectTypeSoSo = CMConnectSoSo
//} DEPRECATED_MSG_ATTRIBUTE("use CMConnectType");;

/// 灯光模式
typedef NS_ENUM(NSUInteger, CameraLightMode)
{
    /// 不支持模式切换 则
    CameraLightModeNotSupport,
    /// 关
    CameraLightModeOff,
    /// 开
    CameraLightModeOn,
    /// 闪烁
    CameraLightModeBlink,
    /// 呼吸
    CameraLightModeBreath,
};

typedef NS_ENUM(NSUInteger, CMMotorAction)
{
    CMMotorActionOff = 0,
    CMMotorActionOn = 1,
    CMMotorActionAuto = 5,
};

/// 乐信SDK 不同设备, 缩放按键可能发送的值不一样, 此枚举区分
typedef NS_ENUM(NSUInteger, CMLexinScaleMode) {
    /// 04 放大 05 缩小
    CMLexinScale0405,
    /// 05/0x25 放大 06/0x26 缩小
    CMLexinScale0506,
};

/// 相机模式
typedef NS_ENUM(NSInteger, CameraMode)
{
    CameraModeNone = -1,

    // BK方案中, SUNUO 设备模式
    /// 挤痘模式
    CameraMode_SUNUO_Whelk = 1,
    /// 采耳
    CameraMode_SUNUO_Ear = 2,
    /// 剔牙
    CameraMode_SUNUO_Tooth = 3,
    
    /// T11Pro+  温和
    CameraMode_SUNUO_Gentle = 1,
    /// T11Pro+  标准
    CameraMode_SUNUO_Standard = 2,
    /// T11Pro+  强劲
    CameraMode_SUNUO_Strong = 3,
    /// T11Pro+ 暂停
    CameraMode_SUNUO_Pasue = 4,
    
    /// C3 柔和模式
    CameraMode_SUNUO_Soft = 1,
    /// C3 深度模式
    CameraMode_SUNUO_Depth = 2,
    /// C3 SPA模式
    CameraMode_SUNUO_SPA = 3,
    
    // BK方案中, Suear 设备模式
    /// 挤痘模式
    CameraMode_Suear_Whelk = 2,
    /// 采耳
    CameraMode_Suear_Ear = 1,
    
    // 四季方案中 黑头仪模式
    /// 正常模式（护理模式） 3:蓝光杀菌
    CameraModeNormal = 0,
    /// 厂测模式
    CameraModeFactory = 1,
    /// 黑头查看模式
    CameraModeLookOver = 2,
    /// 蓝光杀菌
    CameraModeBluray = 3,
};

typedef void(^ProcessVoidBlock)(void);                  // void
typedef void(^ProcessSturctBlock)(void* value);         // struct void* 结构体指针
typedef void(^ProcessObjectBlock)(id object);   // object 对象
typedef void(^ProcessFloatBlock)(float value);  // float 数值
typedef void(^ProcessIntBlock)(NSInteger value);      // int  数值
typedef void(^ProcessBoolBlock)(BOOL value);    // bool
typedef void(^ProcessSavePhotoBlock)(NSString *file);

/// BK方案地址
static NSString *kBKCloudAddress = @"http://192.168.1.1:5520";

#pragma mark - 摄像头状态
typedef NS_ENUM(NSInteger, CameraState)
{
    /// 未定义状态, 不作为没图像的依据, 可能有图
    CameraStateNone,
    /// 异常, 没有图像
    CameraStateNoPicture,
    /// 正常, 有图像
    CameraStateHasPicture
};

#pragma mark - 图片滤镜
typedef NS_ENUM(NSInteger, CameraImageColorEffect)
{
    /// 原图
    CameraImageColorEffectOrigin,
    /// 黑白
    CameraImageColorEffectBlack,
};

/// 错误定义 domain
//FOUNDATION_EXPORT NSString* const CameraErrorDomain;

FOUNDATION_EXPORT NSString* const CMErrorCodeKey;
FOUNDATION_EXPORT NSString* const CMErrorDescKey;
/// 错误码
typedef NS_ENUM(NSInteger, CMErrorCode)
{
    /// 没有错误
    CMErrorNone = 0,
    /// 其他错误, 为其他库内部的错误码, 记录在CMErrorDescKey中
    CMErrorCustom = -1,
    /// 产品 不支持
    CMErrorProductNotSupport = -2,
    /// SSID 不支持
    CMErrorSSIDNotSupport = -3,
    /// app name/bundleid/protocol 等不受支持
    CMErrorAppInfoNotSupport = -4,
    /// License 错误
    CMErrorLicenseError = -5,
    /// 盗版设备
    CMErrorPiracyDevice = -6,
    /// PTP命令发送失败
    CMErrorPTPCMDSendError = -7,
    /// 出图超时
    CMErrorPicTimeout = -8,
    /// 设备未插入或协议不匹配
    CMErrorDeviceNotFound = -9,
    /// 未授权-系统相机权限
    CMErrorUnauthorizedCamera = -10,
    /// 未授权-系统相册权限
    CMErrorUnauthorizedPhotoLibrary = -11,
};

/// 上线状态通知
FOUNDATION_EXTERN NSNotificationName const CMDeviceOnlineNotification;

/// 判断当前设备 modelName 型号
#define CameraModelEqual(name) CMModelEqual(name)
#define CameraFirmwareEqual(firmware) [CameraShareManager.propertiesCache.firmwareVersion isEqualToString:(firmware)]
#define IFSDeviceModelEqual(name) CameraModelEqual(name)

#define CMModelEqual(name)  [CameraShareManager.propertiesCache.modelName isEqualToString:(name)]
#define CMModelsEqual(names) \
({\
    BOOL ret = NO;\
    for (NSString *name in names) {\
        if (CMModelEqual(name)) {\
            ret = YES;\
            break;\
        }\
    }\
    ret;\
})

#define CameraModelHasPrefix(name) [CameraShareManager.propertiesCache.modelName hasPrefix:(name)]
#define CameraModelHasSuffix(name) [CameraShareManager.propertiesCache.modelName hasSuffix:(name)]

#define ToRadian(angle) (angle*M_PI/180.0f)

/// 图片角度偏移
//typedef struct ImageAdjustAngleOffset{
//    bool isValid; // 值是否有效, NO则需要重新获取, 获取到后此值设置为YES
//    int angle;//偏移角度默认，正为顺时针，负为逆时针
//    int x;//横坐标偏移，正为向左，负为向右
//    int y;//纵坐标偏移,正为向上，负为向下
//} ImageAdjustAngleOffset;

// 设备属性常量
typedef NSString * DeviceProperty;

/// ============= 泰享受 =============
//P40耳道镜（有陀螺仪
static DeviceProperty YPCEar = @"WiFi-Camera-c-ear";//一品呈耳道镜





/// ============= Inskam =============
/** YPC109 支持pwm灯光调节功能 */
static DeviceProperty INSKAM_HW_VERSION_YPC109  = @"YPC109";
/**  */
static DeviceProperty INSKAM_HW_VERSION_YPC110  = @"YPC110";
/**  */
static DeviceProperty INSKAM_HW_VERSION_YPC130A = @"YPC130A";
/** YPC401 支持硬件按键放大缩小的功能 */
static DeviceProperty INSKAM_HW_VERSION_YPC401  = @"YPC401";
/** YPC208 支持陀螺仪 */
static DeviceProperty INSKAM_HW_VERSION_YPC208  = @"YPC208";

static DeviceProperty INSKAM_HW_VERSION_YPC109B  = @"YPC109B";

/// ============= 镁拾 =============
/// WIFI粉刺针
static DeviceProperty PAI032 = @"PAI032";
/// WIFI黑头仪
static DeviceProperty Godness = @"Godness";
/// 黑头仪一代 直连
static DeviceProperty PAI016 = @"PAI-016";
